package com.learn.multDataSource.facade;


import com.learn.multDataSource.model.elastic.TRcenum;
import com.learn.multDataSource.model.mysql.TKnow;
import com.learn.multDataSource.service.elastic.EnumService;
import com.learn.multDataSource.service.mysql.KnowService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;

@Component("demoFacade")
public class DemoFacade {

    @Resource
    private EnumService enumService;

    @Resource
    private KnowService knowService;

    public String sayHi() {
        return "hello ";
    }

    @Transactional()
    public void save() {
        TRcenum tRcenum = new TRcenum();
        tRcenum.setBrokerid("1111");
        tRcenum.setEnumdesc("lo");
        tRcenum.setEnumname("test");
        tRcenum.setEnumtypeid("10");
        tRcenum.setEnumvalue("1");
        enumService.save(tRcenum);
        System.out.println(tRcenum.getEnumtypeid());

        TKnow know = new TKnow();
        know.setKnowType("2");
        know.setKnowName("test2");
        know.setAuthorId((long)1);
        know.setAuthorName("xxx");
        know.setCreateTime(new Date());
        know.setUpdateTime(new Date());
        knowService.save(know);
        System.out.println(know.getKnowId());

        int i = 1/0;
    }
}
